﻿using System;

namespace TextEditor
{
    

    public class A_FontItalic : A_Action
    {
        public override string ActionName()
        {
            return "italic";
        }

        public override int CheckState()
        {
            ZYTextChar preChar = base.myOwnerDocument.Content.GetPreChar();
            if (preChar != null)
            {
                return (preChar.FontItalic ? 1 : 0);
            }
            return -1;
        }

        public override A_Action Clone()
        {
            A_FontItalic italic = new A_FontItalic();
            italic.BaseCloneFrom(this);
            return italic;
        }

        public override bool Execute()
        {
            ZYTextChar preChar = base.myOwnerDocument.Content.GetPreChar();
            if (preChar != null)
                base.myOwnerDocument.SetSelectionFontItalic(!preChar.FontItalic);
            return true;
        }

        public override bool isEnable()
        {
            return base.myOwnerDocument.CanModify();
        }
    }
}

